/*
 * 文件名：Client.java
 * 描述： Client.java
 * 修改人：Lo&Wang
 * 修改时间：2016年11月23日
 * 修改内容：新增
 */
package com.lowang.test.thrift;

import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

import com.lowang.test.thrift.ReconnectingThriftClient.Options;
import com.lowang.test.thrift.service.IHelloThriftService;

/**
 * @author zhengmo
 */
public class Client {
    public static void main(String[] args) {
        TTransport transport = null;
        try {
            transport = new TSocket("127.0.0.1", 6161);
            TProtocol protocol = new TBinaryProtocol(transport);
            IHelloThriftService.Client client = new IHelloThriftService.Client(protocol);
            ReconnectingThriftClient.Options op = new Options(2, 100);
            IHelloThriftService.Iface client2 = ReconnectingThriftClient.wrap(client, IHelloThriftService.Client.class.getInterfaces()[0], op);
            transport.open();
            int i=0;
            while(i<100){
                System.out.println(client2.sayHello("你好"));
                i++;
                Thread.sleep(1000);
            }
            transport.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
